package com.ymatou.paymentproxy.testcase;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.TreeMap;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.paymentproxy.parameter.AcquireOrderBean;
import com.ymatou.paymentproxy.parameter.PayOrderEnum;
import com.ymatou.paymentproxy.parameter.PayStatusEnum;
import com.ymatou.paymentproxy.service.AcquireOrderCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;
import com.ymt.utils.tag.P3;
import com.ymttest.business.data.Sign;
import com.ymttest.common.enums.BankIdEnum;
import com.ymttest.database.model.PPBussinessOrder;
import com.ymttest.database.model.PPPayment;
import com.ymttest.database.sqlwapper.DefaultWapper;
import com.ymttest.database.sqlwapper.PaymentDefaultWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;

/**
 * 支付收单接口 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_AcquireOrder {
	private static AcquireOrderBean acquireorderBean;
	private static AcquireOrderCall acquireorderCall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("支付收单接口");
	}

	@Before
	public void caseUp() {
		acquireorderBean = new AcquireOrderBean();
		acquireorderCall = new AcquireOrderCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(acquireorderCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	/**
	 * 初始化一个AcquireOrderBean
	 * 
	 * @return AcquireOrderBean
	 */
	public AcquireOrderBean initAcquireOrder() {
		String orderid = TestDataManager.getClientpaymentId();
		String payPrice = String.valueOf(new Random().nextInt(10) + 1);
		String productName = "自动化测试商品" + TestDataManager.randomStr(10);
		String uid = String.valueOf(new Random().nextInt(100000) + 1000);
		String ip = TestDataManager.getRandomIp();
		acquireorderBean.setAppId("AutoTest");
		acquireorderBean.setBankId(BankIdEnum.CMB.name());
		// 定金或者支付
		acquireorderBean.setBizCode("3");
		acquireorderBean.setCallbackUrl("http://www.ymatou.com/pay/result");
		acquireorderBean.setCurrency("CNY");
		acquireorderBean.setEncoding("65001");
		acquireorderBean.setExt("{\"SHOWMODE\":\"2\",\"PAYMETHOD\":\"2\", \"IsHangZhou\":1}");
		acquireorderBean.setNotifyUrl("http://api.trading.operate.ymatou.com/api/Trading/TradingCompletedNotify");
		acquireorderBean.setOrderId(orderid);
		acquireorderBean.setOrderTime(YMTDateUtil.getSysTime("yyyyMMddHHmmss"));
		acquireorderBean.setOriginAppId("AutoTest");
		acquireorderBean.setPayPrice(payPrice);
		acquireorderBean.setPayType("13");
		acquireorderBean.setProductName(productName);
		acquireorderBean.setSignMethod("MD5");
		acquireorderBean.setTraceId(TestDataManager.getRandomUUID().toString());
		acquireorderBean.setUserId(uid);
		acquireorderBean.setUserIp(ip);
		acquireorderBean.setVersion("1");
		acquireorderBean.setMemo("备注:" + TestDataManager.getRandomNum(3));
		return acquireorderBean;
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_AcquireOrder_001() {
		Logger.start(true, "10支付宝PC支付收单,订单为杭保订单,paymethod2,收单成功");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setPayType("10");
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			Logger.comment("设置此请求调用MOCK系统");
			acquireorderCall.addHeader("Mock", "1");
			String mockid=TestDataManager.getRandomUUID().toString();
			acquireorderCall.addHeader("MockId", mockid);
			acquireorderCall.callService();
			verifyDefReturn();
			Logger.verifyEquals("Form", acquireorderCall.getString("ResultType").toString(), "验证ResultType");
			verifyDB(acquireorderBean);
			String result = acquireorderCall.getString("Result");
			verifyHtmlResult(acquireorderBean, result);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AcquireOrder_002() {
		Logger.start(true, "10支付宝PC支付收单,订单为非杭保订单,paymethod1,收单成功");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setExt("{\"SHOWMODE\":\"1\",\"PAYMETHOD\":\"1\", \"IsHangZhou\":0}");
			acquireorderBean.setPayType("10");
			// 设置了ThirdPartyUserId default_login Y
			acquireorderBean.setThirdPartyUserId(TestDataManager.getRandomUUID().toString());
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			Logger.comment("设置此请求调用MOCK系统");
			acquireorderCall.addHeader("Mock", "1");
			String mockid=TestDataManager.getRandomUUID().toString();
			acquireorderCall.addHeader("MockId", mockid);
			acquireorderCall.callService();
			verifyDefReturn();
			Logger.verifyEquals("Form", acquireorderCall.getString("ResultType").toString(), "验证ResultType");
			verifyDB(acquireorderBean);
			String result = acquireorderCall.getString("Result");
			verifyHtmlResult(acquireorderBean, result);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AcquireOrder_003() {
		Logger.start(true, "10支付宝PC支付收单,订单为非杭保订单,paymethod3,收单成功");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setExt("{\"SHOWMODE\":\"3\",\"PAYMETHOD\":\"3\", \"IsHangZhou\":0}");
			acquireorderBean.setPayType("10");
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			Logger.comment("设置此请求调用MOCK系统");
			acquireorderCall.addHeader("Mock", "1");
			String mockid=TestDataManager.getRandomUUID().toString();
			acquireorderCall.addHeader("MockId", mockid);
			acquireorderCall.callService();
			verifyDefReturn();
			Logger.verifyEquals("Form", acquireorderCall.getString("ResultType").toString(), "验证ResultType");
			verifyDB(acquireorderBean);
			// Map m=(Map)
			// FormatUtil.GSONToObject(acquireorderCall.getString("Result"),
			// Map.class);
			String result = acquireorderCall.getString("Result");
			verifyHtmlResult(acquireorderBean, result);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AcquireOrder_004() {
		Logger.start(true, "11.支付宝WAP支付收单,订单为杭保订单,paymethod2,收单成功");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setExt("{\"SHOWMODE\":\"3\",\"PAYMETHOD\":\"3\", \"IsHangZhou\":1}");
			acquireorderBean.setPayType("11");
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			Logger.comment("设置此请求调用MOCK系统");
			acquireorderCall.addHeader("Mock", "1");
			String mockid=TestDataManager.getRandomUUID().toString();
			acquireorderCall.addHeader("MockId", mockid);
			acquireorderCall.callService();
			verifyDefReturn();
			Logger.verifyEquals("Query", acquireorderCall.getString("ResultType").toString(), "验证ResultType");
			verifyDB(acquireorderBean);
			Logger.comment("验证Result报文");
			// wap目前没有使用,规则暂不清楚,先不验证
			String result=acquireorderCall.getString("Result");
			Logger.verifyIsContains("wappaygw.alipay.com/service/rest.htm", result,  "验证支付宝WAP跳转链接地址");
			verifyWapHtmlResult(acquireorderBean, result);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AcquireOrder_005() {
		Logger.start(true, "13.支付宝-APP支付收单,订单为杭保订单,paymethod2,收单成功");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setExt("{\"SHOWMODE\":\"2\",\"PAYMETHOD\":\"2\", \"IsHangZhou\":1}");
			acquireorderBean.setPayType("13");
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			Logger.comment("设置此请求调用MOCK系统");
			acquireorderCall.addHeader("Mock", "1");
			String mockid=TestDataManager.getRandomUUID().toString();
			acquireorderCall.addHeader("MockId", mockid);
			acquireorderCall.callService();
			verifyDefReturn();
			Logger.verifyEquals("JSON", acquireorderCall.getString("ResultType").toString(), "验证ResultType");
			verifyDB(acquireorderBean);
			verifyAlipayApp(acquireorderBean, acquireorderCall.getString("Result").toString());
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AcquireOrder_006() {
		Logger.start(true, "13.支付宝-APP支付收单,订单为非杭保订单,paymethod2,收单成功");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setExt("{\"SHOWMODE\":\"1\",\"PAYMETHOD\":\"1\", \"IsHangZhou\":0}");
			acquireorderBean.setPayType("13");
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			Logger.comment("设置此请求调用MOCK系统");
			acquireorderCall.addHeader("Mock", "1");
			String mockid=TestDataManager.getRandomUUID().toString();
			acquireorderCall.addHeader("MockId", mockid);
			acquireorderCall.callService();
			verifyDefReturn();
			Logger.verifyEquals("JSON", acquireorderCall.getString("ResultType").toString(), "验证ResultType");
			verifyDB(acquireorderBean);
			verifyAlipayApp(acquireorderBean, acquireorderCall.getString("Result").toString());
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AcquireOrder_007() {
		Logger.start(true, "14.微信-JSAPI支付收单,订单为杭保订单,paymethod1,收单成功");
		try {
			Map m = new DefaultWapper().selectLastWeixinUser();
			String uid = m.get("iYmtUserId").toString();
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setExt("{\"SHOWMODE\":\"1\",\"PAYMETHOD\":\"1\", \"IsHangZhou\":1}");
			acquireorderBean.setPayType("14");
			acquireorderBean.setUserId(uid);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			Logger.comment("设置此请求调用MOCK系统");
			acquireorderCall.addHeader("Mock", "1");
			String mockid=TestDataManager.getRandomUUID().toString();
			acquireorderCall.addHeader("MockId", mockid);
			acquireorderCall.addHeader("MockResult-WeiXin-return_code", "SUCCESS");
			acquireorderCall.addHeader("MockResult-WeiXin-result_code", "SUCCESS");
			Logger.comment("Mock:1,MockResult-WeiXin-return_code:SUCCESS,MockResult-WeiXin-result_code:SUCCESS");
			acquireorderCall.callService();
			verifyDefReturn();
			Logger.verifyEquals("JSON", acquireorderCall.getString("ResultType").toString(), "验证ResultType");
			verifyDB(acquireorderBean);
			verifyWeixin(acquireorderBean, acquireorderCall.getString("Result").toString());
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AcquireOrder_008() {
		Logger.start(true, "15.微信支付收单,订单为杭保订单,paymethod1,收单成功");
		try {
			Map m = new DefaultWapper().selectLastWeixinUser();
			String uid = m.get("iYmtUserId").toString();
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setExt("{\"SHOWMODE\":\"1\",\"PAYMETHOD\":\"1\", \"IsHangZhou\":1}");
			acquireorderBean.setPayType("15");
			acquireorderBean.setUserId(uid);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			Logger.comment("设置此请求调用MOCK系统");
			acquireorderCall.addHeader("Mock", "1");
			String mockid=TestDataManager.getRandomUUID().toString();
			acquireorderCall.addHeader("MockId", mockid);
			acquireorderCall.addHeader("MockResult-WeiXin-return_code", "SUCCESS");
			acquireorderCall.addHeader("MockResult-WeiXin-result_code", "SUCCESS");
			Logger.comment("Mock:1,MockResult-WeiXin-return_code:SUCCESS,MockResult-WeiXin-result_code:SUCCESS");
			acquireorderCall.callService();
			verifyDefReturn();
			Logger.verifyEquals("JSON", acquireorderCall.getString("ResultType").toString(), "验证ResultType");
			verifyDB(acquireorderBean);
			verifyWeixin(acquireorderBean, acquireorderCall.getString("Result").toString());
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_009() {
		Logger.start(false, "不输入AppId,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setAppId(null);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-5000", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("appId should not be empty", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_010() {
		Logger.start(false, "不输入sign,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-5000", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("compairSignedMsg should not be null", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_011() {
		Logger.start(false, "paytype10,输入错误sign,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setPayType("10");
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign+1);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-2001", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("sign not match", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_012() {
		Logger.start(false, "不输入PayType,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setPayType(null);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-9999", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("EntityValidationErrors", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_013() {
		Logger.start(false, "不输入Currency,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setCurrency(null);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-9999", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("EntityValidationErrors", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_014() {
		Logger.start(false, "不输入Encoding,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setEncoding(null);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-2001", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("sign not match", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_015() {
		Logger.start(false, "不输入NotifyUrl,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setNotifyUrl(null);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-9999", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("EntityValidationErrors", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_016() {
		Logger.start(false, "不输入OrderId,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setOrderId(null);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-9999", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("EntityValidationErrors", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_017() {
		Logger.start(false, "不输入OrderTime,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setOrderTime(null);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-9999", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("EntityValidationErrors", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_018() {
		Logger.start(false, "不输入OriginAppId,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setOriginAppId(null);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-9999", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("EntityValidationErrors", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_019() {
		Logger.start(false, "不输入PayPrice,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setPayPrice(null);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-9999", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("值不能为 null。", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_020() {
		Logger.start(false, "不输入PayType,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setPayType(null);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-9999", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("EntityValidationErrors", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_021() {
		Logger.start(false, "不输入ProductName,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setProductName(null);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-9999", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("EntityValidationErrors", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_022() {
		Logger.start(false, "不输入SignMethod,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setSignMethod(null);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-9999", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("EntityValidationErrors", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_023() {
		Logger.start(false, "不输入TraceId,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setTraceId(null);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-9999", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("EntityValidationErrors", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_024() {
		Logger.start(false, "不输入UserIp,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setUserIp(null);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-9999", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("EntityValidationErrors", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_025() {
		Logger.start(false, "不输入Version,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setVersion(null);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-2001", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("sign not match", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_026() {
		Logger.start(false, "输入错误Version,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setVersion("-1");
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-2003", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("version not supported", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AcquireOrder_027() {
		Logger.start(false, "10:支付宝PC,订单重复,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setPayType("10");
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			acquireorderCall.callService();
			Logger.verifyEquals("-2106", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("db error", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AcquireOrder_028() {
		Logger.start(false, "11.支付宝WAP,订单重复,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setPayType("11");
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			acquireorderCall.callService();
			Logger.verifyEquals("-2106", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("db error", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AcquireOrder_029() {
		Logger.start(false, "13.支付宝APP,订单重复,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setPayType("13");
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			acquireorderCall.callService();
			Logger.verifyEquals("-2106", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("db error", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AcquireOrder_030() {
		Logger.start(false, "14.微信 JSAP,订单重复,收单失败");
		try {
			Map m = new DefaultWapper().selectLastWeixinUser();
			String uid = m.get("iYmtUserId").toString();
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setExt("{\"SHOWMODE\":\"1\",\"PAYMETHOD\":\"1\", \"IsHangZhou\":1}");
			acquireorderBean.setPayType("14");
			acquireorderBean.setUserId(uid);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			acquireorderCall.callService();
			Logger.verifyEquals("-2106", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("db error", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AcquireOrder_031() {
		Logger.start(false, "15.微信APP,订单重复,收单失败");
		try {
			Map m = new DefaultWapper().selectLastWeixinUser();
			String uid = m.get("iYmtUserId").toString();
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setExt("{\"SHOWMODE\":\"1\",\"PAYMETHOD\":\"1\", \"IsHangZhou\":1}");
			acquireorderBean.setPayType("15");
			acquireorderBean.setUserId(uid);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			acquireorderCall.callService();
			Logger.verifyEquals("-2106", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("db error", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AcquireOrder_032() {
		Logger.start(false, "14.微信JSAIP,MOCK return_code Fail result_code Fail ,收单失败");
		try {
			Map m = new DefaultWapper().selectLastWeixinUser();
			String uid = m.get("iYmtUserId").toString();
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setExt("{\"SHOWMODE\":\"1\",\"PAYMETHOD\":\"1\", \"IsHangZhou\":1}");
			acquireorderBean.setPayType("14");
			acquireorderBean.setUserId(uid);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			Logger.comment("设置此请求调用MOCK系统");
			acquireorderCall.addHeader("Mock", "1");
			String mockid=TestDataManager.getRandomUUID().toString();
			acquireorderCall.addHeader("MockId", mockid);
			acquireorderCall.addHeader("MockResult-WeiXin-return_code", "FAIL");
			acquireorderCall.addHeader("MockResult-WeiXin-result_code", "FAIL");
			acquireorderCall.addHeader("MockResult-WeiXin-return_msg", "MOCK_FAIL_FAIL");
			Logger.comment("Mock:1,MockResult-WeiXin-return_code:FAIL,MockResult-WeiXin-result_code:FAIL,MockResult-WeiXin-return_msg:MOCK_FAIL_FAIL");
			acquireorderCall.callService();
			Logger.verifyEquals("-2100", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("MOCK_FAIL_FAIL", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AcquireOrder_033() {
		Logger.start(false, "14.微信JSAIP,MOCK return_code Success result_code Fail ,收单失败");
		try {
			Map m = new DefaultWapper().selectLastWeixinUser();
			String uid = m.get("iYmtUserId").toString();
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setExt("{\"SHOWMODE\":\"1\",\"PAYMETHOD\":\"1\", \"IsHangZhou\":1}");
			acquireorderBean.setPayType("14");
			acquireorderBean.setUserId(uid);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			Logger.comment("设置此请求调用MOCK系统");
			acquireorderCall.addHeader("Mock", "1");
			String mockid=TestDataManager.getRandomUUID().toString();
			acquireorderCall.addHeader("MockId", mockid);
			acquireorderCall.addHeader("MockResult-WeiXin-return_code", "SUCCESS");
			acquireorderCall.addHeader("MockResult-WeiXin-result_code", "FAIL");
			acquireorderCall.addHeader("MockResult-WeiXin-return_msg", "MOCK_SUCCESS_FAIL");
			Logger.comment("Mock:1,MockResult-WeiXin-return_code:FAIL,MockResult-WeiXin-result_code:FAIL,MockResult-WeiXin-return_msg:MOCK_FAIL_FAIL");
			
			acquireorderCall.callService();
			Logger.verifyEquals("-2100", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
//			TODO mock没有返回 result error 待加
//			Logger.verifyIsContains("MOCK_SUCCESS_FAIL", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AcquireOrder_034() {
		Logger.start(false, "15.微信App,MOCK return_code Fail result_code Fail ,收单失败");
		try {
			Map m = new DefaultWapper().selectLastWeixinUser();
			String uid = m.get("iYmtUserId").toString();
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setExt("{\"SHOWMODE\":\"1\",\"PAYMETHOD\":\"1\", \"IsHangZhou\":1}");
			acquireorderBean.setPayType("15");
			acquireorderBean.setUserId(uid);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.addHeader("Mock", "1");
			String mockid=TestDataManager.getRandomUUID().toString();
			acquireorderCall.addHeader("MockId", mockid);
			acquireorderCall.addHeader("MockResult-WeiXin-return_code", "FAIL");
			acquireorderCall.addHeader("MockResult-WeiXin-result_code", "FAIL");
			acquireorderCall.addHeader("MockResult-WeiXin-return_msg", "MOCK_FAIL_FAIL");
			acquireorderCall.callService();
			Logger.verifyEquals("-2100", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("MOCK_FAIL_FAIL", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AcquireOrder_035() {
		Logger.start(false, "15.微信APP,MOCK return_code Success result_code Fail ,收单失败");
		try {
			Map m = new DefaultWapper().selectLastWeixinUser();
			String uid = m.get("iYmtUserId").toString();
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setExt("{\"SHOWMODE\":\"1\",\"PAYMETHOD\":\"1\", \"IsHangZhou\":1}");
			acquireorderBean.setPayType("15");
			acquireorderBean.setUserId(uid);
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.addHeader("Mock", "1");
			String mockid=TestDataManager.getRandomUUID().toString();
			acquireorderCall.addHeader("MockId", mockid);
			acquireorderCall.addHeader("MockResult-WeiXin-return_code", "SUCCESS");
			acquireorderCall.addHeader("MockResult-WeiXin-result_code", "FAIL");
			acquireorderCall.addHeader("MockResult-WeiXin-return_msg", "MOCK_SUCCESS_FAIL");
			acquireorderCall.callService();
			Logger.verifyEquals("-2100", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
//			TODO mock没有返回 result error 待加
//			Logger.verifyIsContains("MOCK_SUCCESS_FAIL", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_036() {
		Logger.start(false, "paytype11,输入错误sign,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setPayType("11");
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign+1);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-2001", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("sign not match", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_037() {
		Logger.start(false, "paytype13,输入错误sign,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setPayType("13");
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign+1);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-2001", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("sign not match", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_038() {
		Logger.start(false, "paytype14,输入错误sign,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setPayType("14");
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign+1);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-2001", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("sign not match", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AcquireOrder_039() {
		Logger.start(false, "paytype15,输入错误sign,收单失败");
		try {
			acquireorderBean = initAcquireOrder();
			acquireorderBean.setPayType("15");
			String sign = new Sign().signMd5(acquireorderBean, Sign.autoTestKey);
			acquireorderBean.setSign(sign+1);
			acquireorderCall.setData(acquireorderBean);
			acquireorderCall.callService();
			Logger.verifyEquals("-2001", acquireorderCall.getString("ErrorCode").toString(), "验证ErrorCode");
			Logger.verifyIsContains("sign not match", acquireorderCall.getString("ErrorMessage"), "验证ErrorMessage包含内容");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	private void verifyWeixin(AcquireOrderBean acqbean, String string) {
		Logger.comment("验证微信JSAPI Result报文");
		HashMap mresult = (HashMap) FormatUtil.GSONToObject(string, HashMap.class);
		// "{\"AppID\":\"wxa06ebe9f39751792\",\"TimeStamp\":\"1460692208\",\"NonceStr\":\"a769d779901e4c539be975450a24beef\",\"Package\":\"prepay_id=wx201604151150101a3f453bb40847302088\",\"SignType\":\"MD5\",\"Sign\":\"973E138DC78EA558964D331E321E510B\"}","ResultType":"JSON"}
		Logger.verifyNotNull(mresult.get("AppID"), "验证AppID 公众号");
		Logger.verifyNotNull(mresult.get("TimeStamp"), "验证TimeStamp非空");
		Logger.verifyEquals(true,mresult.get("TimeStamp").toString().length()==10, "验证TimeStamp长度等于10");
		Logger.verifyNotNull(mresult.get("NonceStr"), "验证NonceStr非空");
		Logger.verifyEquals(true,mresult.get("NonceStr").toString().length()<=32, "验证NonceStr长度小于32");
		Logger.verifyNotNull(mresult.get("Package"), "验证Package非空");
		String sign = null;
		String mysign = null;
		if (acqbean.getPayType().equals("15")) {
			Logger.verifyEquals("Sign=WXPay", mresult.get("Package"), "验证SignType");
			sign = mresult.get("Sign").toString();
			String merchantId = mresult.get("MerchantId").toString();
			/*
			 * [SignAlias("appid")] public string AppID { get; set; }
			 * [SignAlias("partnerid")] public string MerchantId { get; set; }
			 * [SignAlias("prepayid")] public string PayToken { get; set; }
			 * [SignAlias("timestamp")] public string TimeStamp { get; set; }
			 * [SignAlias("noncestr")] public string NonceStr { get; set; }
			 * [SignAlias("package")] public string Package { get; set; }
			 * [SignIgnore] public string Sign { get; set; }
			 */
			Map resetmap = new TreeMap();
			resetmap.put("appid", mresult.get("AppID"));
			resetmap.put("partnerid", mresult.get("MerchantId"));
			resetmap.put("prepayid", mresult.get("PayToken"));
			resetmap.put("timestamp", mresult.get("TimeStamp"));
			resetmap.put("package", mresult.get("Package"));
			resetmap.put("noncestr", mresult.get("NonceStr"));
			Logger.debug("15 resetmap:" + resetmap);
			mysign = new Sign().signMd5(resetmap, Sign.weixinAppKey);
		} else if (acqbean.getPayType().equals("14")) {
			Logger.verifyEquals("MD5", mresult.get("SignType"), "验证SignType");
			sign = mresult.get("Sign").toString();
			/*
			 * [SignAlias("appId")] public string AppID { get; set; }
			 * [SignAlias("timeStamp")] public string TimeStamp { get; set; }
			 * [SignAlias("nonceStr")] public string NonceStr { get; set; }
			 * [SignAlias("package")] public string Package { get; set; }
			 * [SignAlias("signType")] public string SignType { get; set; }
			 * [SignIgnore] public string Sign { get; set; }
			 */
			Map resetmap = new TreeMap();
			resetmap.put("appId", mresult.get("AppID"));
			resetmap.put("timeStamp", mresult.get("TimeStamp"));
			resetmap.put("package", mresult.get("Package"));
			resetmap.put("nonceStr", mresult.get("NonceStr"));
			resetmap.put("signType", mresult.get("SignType"));
			Logger.debug("14 resetmap:" + resetmap);
			mysign = new Sign().signMd5(resetmap,Sign.weixinJSAPIKey);
		}
		Logger.verifyEquals(mysign.toLowerCase(), sign.toLowerCase(), "验证Sign");
	}

	/**
	 * 验证默认返回信息
	 * 
	 * @throws Exception
	 */
	private void verifyDefReturn() throws Exception {
		Logger.comment("验证默认返回报文");
		Logger.verifyEquals("0", acquireorderCall.getString("ErrorCode"), "验证ErrorCode");
		Logger.verifyEquals(acquireorderBean.getVersion(), acquireorderCall.getString("Version"), "验证Version");
		Logger.verifyEquals(acquireorderBean.getAppId(), acquireorderCall.getString("AppId"), "验证AppId");
		Logger.verifyEquals(acquireorderBean.getTraceId(), acquireorderCall.getString("TraceId").toString(),
				"验证TraceId");
	}

	/**
	 * 验证alipayapp 返回
	 * 
	 * @param acqbean
	 * @param result
	 * @throws Exception
	 */
	private void verifyAlipayApp(AcquireOrderBean acqbean, String result) throws Exception {
		Logger.comment("验证支付宝APP Result报文");
		HashMap mext = (HashMap) FormatUtil.GSONToObject(acqbean.getExt(), HashMap.class);
		int isHangzhou = Double.valueOf(mext.get("IsHangZhou").toString()).intValue();
		Map m = (Map) FormatUtil.GSONToObject(acquireorderCall.getString("Result"), Map.class);
		Logger.verifyNotNull(m.get("Sign"), "验证Sign非空");
		Logger.verifyEquals("2088701734809577", m.get("Partner"), "验证partner合作者身份ID");
		Logger.verifyEquals("ap.ymt@ymatou.com", m.get("SellerId"), "验证SellerId买家支付宝账号");
		PPBussinessOrder ppb = new PaymentDefaultWapper().selectPPBussinessorderByTraceId(acqbean.getTraceId()).get(0);
		String businessoid = ppb.getBussinessOrderId();
		PPPayment ppm = new PaymentDefaultWapper().selectPPPaymentByBussinessOrderId(businessoid).get(0);
		String trandno = ppm.getPaymentId();
		Logger.verifyEquals(trandno, m.get("OutTradeNo"), "验证OutTradeNo");
		Logger.verifyEquals(acqbean.getProductName(), m.get("Subject"), "验证Subject");
		Logger.verifyEquals(true,
				TestDataManager.equalsBigDecimal(new BigDecimal(m.get("TotalFee").toString()), acqbean.getPayPrice()),
				"验证total_fee:" + m.get("TotalFee"));
		Logger.verifyEquals("http://" + EnvSetup.getEnv() + ".paymentproxy.ymatou.com/notify/" + acqbean.getPayType(),
				m.get("NotifyUrl"), "验证NotifyUrl");
		Logger.verifyEquals("mobile.securitypay.pay", m.get("Service"), "验证Service");
		Logger.verifyEquals("1", m.get("PaymentType"), "验证PaymentType");
		Logger.verifyEquals("utf-8", m.get("InputCharset"), "验证InputCharset");
		Logger.verifyEquals("10d", m.get("ItBPay"), "验证ItBPay");
		Logger.verifyEquals("RSA", m.get("SignType"), "验证SignType");
		Logger.verifyEquals(true, m.get("QuerySuccess"), "验证QuerySuccess");
		Logger.verifyEquals("成功", m.get("Message"), "验证Message");
		Logger.comment("验证EncryptStr");
		Map mencrypt = FormatUtil.httpStringToMap(m.get("EncryptStr").toString());
		Logger.verifyNotNull(mencrypt.get("sign"), "验证Sign非空");
		Logger.verifyEquals("2088701734809577", mencrypt.get("partner"), "验证partner合作者身份ID");
		Logger.verifyEquals("ap.ymt@ymatou.com", mencrypt.get("seller_id"), "验证seller_id买家支付宝账号");
		Logger.verifyEquals(trandno, mencrypt.get("out_trade_no"), "验证out_trade_no");
		Logger.verifyEquals(acqbean.getProductName(), mencrypt.get("subject"), "验证subject");
		Logger.verifyEquals(
				true,
				TestDataManager.equalsBigDecimal(new BigDecimal(mencrypt.get("total_fee").toString()),
						acqbean.getPayPrice()), "验证total_fee:" + mencrypt.get("total_fee"));
		Logger.verifyEquals("http://" + EnvSetup.getEnv() + ".paymentproxy.ymatou.com/notify/" + acqbean.getPayType(),
				mencrypt.get("notify_url"), "验证notify_url");
		Logger.verifyEquals("mobile.securitypay.pay", mencrypt.get("service"), "验证service");
		Logger.verifyEquals("1", mencrypt.get("payment_type"), "验证payment_type");
		Logger.verifyEquals("utf-8", mencrypt.get("_input_charset"), "验证_input_charset");
		Logger.verifyEquals("10d", mencrypt.get("it_b_pay"), "验证it_b_pay");
		Logger.verifyEquals("RSA", mencrypt.get("sign_type"), "验证sign_type");
		Logger.verifyEquals("m.alipay.com", mencrypt.get("show_url"), "验证show_url");
		// 杭保实名，非杭保不验
		if (isHangzhou == 1) {
			Logger.verifyEquals("T", mencrypt.get("rn_check"), "验证rn_check");
		}
		Logger.verifyNotNull(mencrypt.get("sign"), "验证sign非空");
	}

	/**
	 * 校验Html Form返回 支付宝PC支付
	 * 
	 * @param acqbean
	 * @param result
	 * @throws Exception
	 */
	private void verifyHtmlResult(AcquireOrderBean acqbean, String result) throws Exception {
		Logger.comment("验证支付宝PC Result");
		Map m = new HashMap<String, String>();
		List<String> namelist = TestDataManager.getRegexList(result, "(?<=name=\").*?(?=\")");
		List<String> valuelist = TestDataManager.getRegexList(result, "(?<=value=\").*?(?=\")");

		if (valuelist.size() == namelist.size()) {
			for (int i = 0; i < namelist.size(); i++) {
				m.put(namelist.get(i), valuelist.get(i));
			}
		} else {
			throw new Exception("verifyResult失败，结果集name value 不匹配");
		}
		HashMap mext = (HashMap) FormatUtil.GSONToObject(acqbean.getExt(), HashMap.class);
		String showmode = mext.get("SHOWMODE").toString();
		String paymethod = mext.get("PAYMETHOD").toString();
		int isHangzhou = Double.valueOf(mext.get("IsHangZhou").toString()).intValue();
		// {subject=自动化测试商品Tdje3wW6ux, sign_type=MD5,
		// notify_url=http://sit1.paymentproxy.ymatou.com/notify/10,
		// out_trade_no=393671933455900796208,
		// return_url=http://sit1.paymentproxy.ymatou.com/callback/10,
		// sign=d68b1115ca3d6aa843cccfa29d0c56c6,
		// _input_charset=utf-8, exter_invoke_ip=208.62.144.214,
		// buyer_info={&quot;needBuyerRealnamed&quot;:&quot;T&quot;},
		// total_fee=7.00, product_code=FAST_INSTANT_TRADE_PAY,
		// service=alipay.acquire.page.createandpay, paymethod=bankPay,
		// partner=2088701734809577, anti_phishing_key=KP3Do5rHfZeUDz5XTw==,
		// seller_email=ap.ymt@ymatou.com, payment_type=1,
		// extend_parameters={&quot;qrPayMode&quot;:&quot;2&quot;}}
		PPBussinessOrder ppb = new PaymentDefaultWapper().selectPPBussinessorderByTraceId(acqbean.getTraceId()).get(0);
		String businessoid = ppb.getBussinessOrderId();
		PPPayment ppm = new PaymentDefaultWapper().selectPPPaymentByBussinessOrderId(businessoid).get(0);
		String trandno = ppm.getPaymentId();
		Logger.verifyEquals(acqbean.getProductName(), m.get("subject"), "验证subject");
		Logger.verifyEquals(acqbean.getSignMethod(), m.get("sign_type"), "验证sign_type");
		Logger.verifyEquals("http://" + EnvSetup.getEnv() + ".paymentproxy.ymatou.com/notify/" + acqbean.getPayType(),
				m.get("notify_url"), "验证notify_url");
		Logger.verifyEquals(trandno, m.get("out_trade_no"), "验证out_trade_no");
		Logger.verifyEquals(
				"http://" + EnvSetup.getEnv() + ".paymentproxy.ymatou.com/callback/" + acqbean.getPayType(),
				m.get("return_url"), "验证return_url");
		// sign算法未知
		Logger.verifyNotNull(m.get("sign"), "验证sign非空");
		Logger.verifyEquals("utf-8", m.get("_input_charset"), "验证_input_charset");
		Logger.verifyEquals(acqbean.getUserIp(), m.get("exter_invoke_ip"), "验证exter_invoke_ip");
		Logger.verifyEquals(true,
				TestDataManager.equalsBigDecimal(new BigDecimal(m.get("total_fee").toString()), acqbean.getPayPrice()),
				"验证total_fee:" + m.get("total_fee"));
		// TODO ?
		// AcquireOrderRequest.Ext.PAYMETHOD creditCard、bankPay、directPay
		if (isHangzhou == 1) {
			Logger.comment("验证杭保信息");
			Logger.verifyEquals("{&quot;needBuyerRealnamed&quot;:&quot;T&quot;}", m.get("buyer_info"),
					"验证buyer_info买家信息");
			Logger.verifyEquals("alipay.acquire.page.createandpay", m.get("service"), "验证service统一下单并支付");
			Logger.verifyEquals("FAST_INSTANT_TRADE_PAY", m.get("product_code"), "验证product_code订单业务类型");
			Logger.verifyEquals("{&quot;qrPayMode&quot;:&quot;" + showmode + "&quot;}", m.get("extend_parameters"),
					"验证extend_parameters公用业务扩展信息");
		} else {
			Logger.comment("验证非杭保信息");
			Logger.verifyEquals(acqbean.getBankId(), m.get("defaultbank"), "验证defaultbank默认银行");
			Logger.verifyEquals("create_direct_pay_by_user", m.get("service"), "验证service统一下单并支付");
			Logger.verifyEquals(acqbean.getThirdPartyUserId() == null ? "N" : "Y", m.get("default_login"),
					"验证default_login默认登录");
			Logger.verifyEquals(showmode, m.get("qr_pay_mode"), "验证qr_pay_mode扫码方式");
		}
		Logger.comment("验证paymethod");
		if (paymethod.equals("1")) {
			Logger.verifyEquals("creditCard", m.get("paymethod"), "验证paymethod");
		} else if (paymethod.equals("2")) {
			Logger.verifyEquals("bankPay", m.get("paymethod"), "验证paymethod");
		} else if (paymethod.equals("3")) {
			Logger.verifyEquals("directPay", m.get("paymethod"), "验证paymethod");
		}

		// 固定
		Logger.verifyEquals("2088701734809577", m.get("partner"), "验证partner合作者身份ID");
		Logger.verifyNotNull(m.get("anti_phishing_key"), "验证anti_phishing_key防钓鱼时间戳");
		Logger.verifyEquals("ap.ymt@ymatou.com", m.get("seller_email"), "验证seller_email买家支付宝账号");
		Logger.verifyEquals("1", m.get("payment_type"), "验证payment_type 1（商品购买）");
	}
	/**
	 * 校验Html Form返回 支付宝PC支付
	 * 
	 * @param acqbean
	 * @param result
	 * @throws Exception
	 */
	private void verifyWapHtmlResult(AcquireOrderBean acqbean, String result) throws Exception {
		Logger.comment("验证支付宝wap Result");
		String uri=result;
		Logger.comment("Location uri:"+uri);
		//解析其参数
		String httpp=uri.substring(uri.indexOf("?")+1);
		Map m=FormatUtil.httpStringToMap(httpp);
		
		Logger.debug("=============="+m);
		HashMap mext = (HashMap) FormatUtil.GSONToObject(acqbean.getExt(), HashMap.class);
		String showmode = mext.get("SHOWMODE").toString();
		String paymethod = mext.get("PAYMETHOD").toString();
		int isHangzhou = Double.valueOf(mext.get("IsHangZhou").toString()).intValue();
		// {subject=自动化测试商品Tdje3wW6ux, sign_type=MD5,
		// notify_url=http://sit1.paymentproxy.ymatou.com/notify/10,
		// out_trade_no=393671933455900796208,
		// return_url=http://sit1.paymentproxy.ymatou.com/callback/10,
		// sign=d68b1115ca3d6aa843cccfa29d0c56c6,
		// _input_charset=utf-8, exter_invoke_ip=208.62.144.214,
		// buyer_info={&quot;needBuyerRealnamed&quot;:&quot;T&quot;},
		// total_fee=7.00, product_code=FAST_INSTANT_TRADE_PAY,
		// service=alipay.acquire.page.createandpay, paymethod=bankPay,
		// partner=2088701734809577, anti_phishing_key=KP3Do5rHfZeUDz5XTw==,
		// seller_email=ap.ymt@ymatou.com, payment_type=1,
		// extend_parameters={&quot;qrPayMode&quot;:&quot;2&quot;}}
		PPBussinessOrder ppb = new PaymentDefaultWapper().selectPPBussinessorderByTraceId(acqbean.getTraceId()).get(0);
		String businessoid = ppb.getBussinessOrderId();
		PPPayment ppm = new PaymentDefaultWapper().selectPPPaymentByBussinessOrderId(businessoid).get(0);
		String trandno = ppm.getPaymentId();
		Logger.verifyEquals(acqbean.getSignMethod(), m.get("sec_id"), "验证sec_id");
		Logger.verifyEquals("xml", m.get("format"), "验证format");
		Logger.verifyEquals("2088701734809577", m.get("partner"), "验证partner");
		Logger.verifyEquals("alipay.wap.auth.authAndExecute", m.get("service"), "验证service");
	}
	private void verifyDB(AcquireOrderBean acqbean) throws InterruptedException {
		Logger.comment("验证表pp_bussinessorder");
		PPBussinessOrder ppb = new PaymentDefaultWapper().selectPPBussinessorderByTraceId(acqbean.getTraceId()).get(0);
		Logger.verifyEquals(acqbean.getAppId(), ppb.getAppId(), "验证AppId");
		Logger.verifyEquals(acqbean.getOriginAppId(), ppb.getOriginAppId(), "验证OriginAppId");
		Logger.verifyEquals(acqbean.getOrderId(), ppb.getOrderId(), "验证OrderId");
		Logger.verifyEquals(acqbean.getPayType(), ppb.getPayType(), "验证PayType");
		Logger.verifyEquals(true, TestDataManager.equalsBigDecimal(ppb.getOrderPrice(), acqbean.getPayPrice()),
				"验证PayPrice:" + ppb.getOrderPrice());
		Logger.verifyEquals(acqbean.getCurrency(), ppb.getCurrencyType(), "验证CurrencyType");
		Logger.verifyEquals(acqbean.getUserId(), ppb.getUserId().toString(), "验证UserId");
		Logger.verifyEquals(acqbean.getVersion(), ppb.getVersion().toString(), "验证Version");
		Logger.verifyEquals(acqbean.getTraceId(), ppb.getTraceId(), "验证TraceId");
		Logger.verifyEquals(acqbean.getOrderTime(), ppb.getOrderTime(), "验证OrderTime");
		Logger.verifyEquals(acqbean.getUserIp(), ppb.getClientIp(), "验证ClientIp");
		Logger.verifyEquals(acqbean.getCallbackUrl(), ppb.getCallbackUrl(), "验证CallbackUrl");
		Logger.verifyEquals(acqbean.getNotifyUrl(), ppb.getNotifyUrl(), "验证NotifyUrl");
		Logger.verifyEquals(acqbean.getProductName(), ppb.getProductName(), "验证ProductName");
		Logger.verifyEquals(acqbean.getEncoding(), ppb.getCodePage().toString(), "验证CodePage");
		Logger.verifyEquals(acqbean.getExt(), ppb.getExt(), "验证Ext");
		Logger.verifyEquals(acqbean.getSignMethod(), ppb.getSignMethod(), "验证SignMethod");
		Logger.verifyEquals(acqbean.getBizCode(), ppb.getBizCode().toString(), "验证BizCode");
		Logger.verifyEquals(PayStatusEnum.Init.getValue(), ppb.getOrderStatus(), "验证OrderStatus");
		Logger.verifyEquals(acqbean.getMemo(), ppb.getMemo(), "验证Memo");
		// ThirdPartyUserId回调的时候填入
		// ThirdPartyUserType暂时没有没用
		// NotifyStatus暂时没有没用
		String businessoid = ppb.getBussinessOrderId();
		Logger.comment("验证表pp_payment");
		PPPayment ppm = new PaymentDefaultWapper().selectPPPaymentByBussinessOrderId(businessoid).get(0);
		Logger.verifyEquals(businessoid, ppm.getBussinessOrderId(), "验证businessoid");
		Logger.verifyNotNull(ppm.getPaymentId(), "验证PaymentId");
		Logger.verifyEquals(17,ppm.getPaymentId().length(), "验证PaymentId长度17位");
		Logger.verifyEquals(acqbean.getPayType(), ppm.getPayType(), "验证PayType");
		Logger.verifyEquals(true, TestDataManager.equalsBigDecimal(ppm.getPayPrice(), acqbean.getPayPrice()),
				"验证PayPrice:" + ppb.getOrderPrice());
		Logger.verifyEquals(acqbean.getCurrency(), ppm.getPayCurrencyType(), "验证PayCurrencyType");
		Logger.verifyEquals(acqbean.getBankId(), ppm.getBankId(), "验证BankId");
		Logger.verifyEquals(PayOrderEnum.Init.getValue(), ppm.getPayStatus(), "验证PayStatus");
		// 下列字段回调时才有
		// InstitutionPaymentId null
		// ActualPayCurrencyType null
		// ExchangeRate null
		// CardType NULL
		// PayerId NULL
		// CheckStatus ?
	}
}